export default {
  state: {
    name: 'HanMeiMei'
  },
  getters: {
    firstName(state) {
      return state.name + ' 1111 ';
    },
    twoName(state, getters) {
      return getters.firstName + ' 222 ';
    },
    threeName(state, getters, rootState) {
      return getters.twoName + ' 333 ' + rootState.students[1].name;
    }
  },
  mutations: {
    updateName(state, payload) {
      return state.name = payload.name;
    }
  },
  actions: {
    aUpdateName(context, payload) {
      return new Promise((resolve) => {
        setTimeout(() => {
          context.commit('updateName', payload)
          resolve('异步修改名称完成')
        }, 1000)
      })
    }
  }
}
